<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;

class UserModel extends Model
{
    protected $table = 'users';
    protected $hidden = ['password'];

    // 角色常量
    const ROLE_ADMIN = 'admin';
    const ROLE_TEACHER = 'teacher';
    const ROLE_STUDENT = 'student';

    // 关联成员信息（学生）
    public function member()
    {
        return $this->hasOne(MemberModel::class, 'user_id');
    }

    // 关联负责的项目（教师）
    public function projects()
    {
        return $this->belongsToMany(ProjectModel::class, 'project_teachers', 'project_id', 'teacher_id');
    }
}